#!/bin/bash

# correct-log.sh mta-track.log
#
# Script that reads a log file produced by mta-track.sh and corrects
# some known problems with the "Registered for:" strings found in the
# whois after being processed by mta-trach.sh. Note that the
# input file is overwritten with the corrections.
#
# Syntax:
#
#    $ ./correct-log.sh mta-track.log
#
# mta-track.log: the log file produced by mta-track.sh
#
#
# v0.3  12 Sep 2007
#
# Author: Ramon Casero <ramon.casero@oucs.ox.ac.uk>
# Copyright © 2007 University of Oxford
#
# This file is part of mta-tracker.
#
# mta-tracker is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# mta-tracker is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with mta-tracker.  If not, see <http://www.gnu.org/licenses/>.
#
# ChangeLog
#
# * 2008-08-21 (rcasero):
#
#   ** Upgrade licence to GPL v3.
#
# * 2007-09-12 (rcasero): v0.3.
#
#   ** Add more strings to be corrected.
#
# * 2007-08-28 (rcasero): v0.2.
#
#   ** No need to correct closing whitespaces, as these are removed
#   now by get-institution-from-domain.sh.
#
# * 2007-06-27 (rcasero): v0.1. First running version.
 
# syntax message
usage() {
    echo "Syntax: `basename $0` mta-track.log"
}

# check number of input arguments
if [ ! $# -eq 1 ]
    then
    usage
    exit 1
fi

# give input argument easier names
log=$1

# ad-hoc replacement of known troublesome institution strings
sed  -i 's/oxacuk\t/university of oxford\t/' "$log"
sed -i 's/aberdeen college students\t/aberdeen college\t/' "$log"
sed -i 's/academy of medical science\t/academy of medical sciences\t/' "$log"
sed -i 's/aim higher/aimhigher/' "$log"
sed -i 's/british association for ameriacn studies/british association for american studies/' "$log"
sed -i 's/oxford university\tbm14.ac.uk/bm14\tbm14.ac.uk/' "$log"
sed -i 's/oxford university\tvideoworks.ac.uk/videoworks\tvideoworks.ac.uk/' "$log"
sed  -i 's/university of the west of england\t/university of the west of england bristol\t/' "$log"
sed  -i 's/bristol university of the west of england\t/university of the west of england bristol\t/' "$log"
sed  -i 's/dartington college of art\t/dartington college of arts\t/' "$log"
sed  -i 's/university of central england\t/university of central england in birmingham\t/' "$log"
